<a class="dropdown-trigger" id="book-chapters-trigger" data-panel-id="chapters-dropdown" href="#">Chapters ▾</a>
{{ $chapter_count := len (index (.Scratch.Get "book") "chapters") }}
{{ $first_chapter_left_column := 0 }}
{{ $last_chapter_left_column := math.Floor (div $chapter_count 3.0) }}
{{ $first_chapter_middle_column := add $last_chapter_left_column 1 }}
{{ $last_chapter_middle_column := math.Ceil (div $chapter_count 1.5) }}
{{ $first_chapter_right_column := add $last_chapter_middle_column 1 }}
{{ $last_chapter_right_column := $chapter_count }}
<div class='dropdown-panel' id='chapters-dropdown'>
  <div class='three-column'>
    <div class="column-left">
      {{ .Scratch.Set "first_chapter" $first_chapter_left_column }}
      {{ .Scratch.Set "last_chapter" $last_chapter_left_column }}
      {{ partial "chapter_listings.html" . }}
    </div>
    <div class='column-middle'>
      {{ .Scratch.Set "first_chapter" $first_chapter_middle_column }}
      {{ .Scratch.Set "last_chapter" $last_chapter_middle_column }}
      {{ partial "chapter_listings.html" . }}
    </div>
    <div class='column-right'>
      {{ .Scratch.Set "first_chapter" $first_chapter_right_column }}
      {{ .Scratch.Set "last_chapter" $last_chapter_right_column }}
      {{ partial "chapter_listings.html" . }}
    </div>
  </div>
</div>
